﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using echarts.data.Entity;
using SqlSugar;

namespace echarts.data
{
    public class DataBase
    {
        public static SqlSugarClient Instance
        {
            get { return new SqlSugarClient(new ConnectionConfig()
            {
                DbType = DbType.Sqlite,
                ConnectionString = Config.ConnectionString,
                InitKeyType = InitKeyType.Attribute,
                IsAutoCloseConnection = true
            });}
        }

        public static void CreateDataBase()
        {
            try
            {
                Instance.DbMaintenance.CreateDatabase();
                DataBase.Instance.CodeFirst.InitTables(typeof(ProductData));
            }
            catch (Exception e)
            {
                
            }
        }
    }
}
